1. Field of the Invention
The present invention relates to a computer capable of effectively using a register by recognizing a use state of the register in interruption processing or the like caused by executing a program.
2. Description of the Related Art
In a computer, the following processing is generally performed during execution of a program. For example, when the program is discontinued by procedure calling or interruption processing, a register is saved. In contrast to this, when control is returned from a procedure, or the program which has been interrupted by the interruption processing is continuously executed, the register is returned.
However, the conventional machine has no means for recognizing a register supposed to store values for normally operating a program during execution of the procedure calling or interruption processing.
As a result, in the conventional machine, when the procedure calling or interruption processing is to be performed, it is not recognized which register is required after the program is continued. Therefore, in a conventional machine, all registers including registers which need not be saved are saved, and, as in a returning operation, all the registers including registers which need not be returned are returned. This operation is an important factor for prolonging an execution time of the program.
In the procedure calling, for example, a case wherein a new procedure B is called from a procedure A will be described below. In this case, a register may be used after control is returned from the procedure B to the procedure A, and the value of the register changed by the procedure B must often be saved.
There are two methods for saving a register. The first method is a method of saving a register on a caller side, i.e., on the procedure A (to be referred to as caller saved convention). The second method is a method of saving a register on a callee side, i.e., the procedure B (to be referred to as callee saved convention).
According to the first method, in order to perform a saving operation in the procedure A, it is not recognized which register can be changed in the procedure B. Therefore, all registers which may be used after control is returned from the procedure B must be saved regardless of whether the registers are changed in the procedure B. In contrast to this, according to the second method, it is not recognized which register is used in the procedure A after control is returned from the procedure B. Therefore, all registers which are to be changed in the procedure B must be saved regardless of whether these registers are used in the procedure A after control is returned from the procedure B. For this reason, in both the first and second methods, an operation for saving registers which need not be saved is performed.
In the interruption processing, a case wherein a currently executed program is interrupted by interruption processing such as a trap or interruption will be described below. In this case, a register used during the interruption processing must be saved to continue the program. However, since it is not recognized which register is required after the program is continued, an operation for saving all registers, i.e., an operation for saving registers which need not be saved, is performed.
In returning registers, as in the saving of registers, an operation for returning registers which need not be returned is performed in each of the procedure calling and the interruption processing.
As described above, when the conventional procedure calling and interruption processing are to be performed, it is not recognized which register is a register whose value is required to normally operate an execution program. As described above, in all the procedure or interruption processing, all registers are saved/returned. Therefore, since saving/returning operations of the registers are redundant, an execution speed of the program is decreased.
A program generally consists of several procedures. In order to minimize saving/returning operations of registers, different registers are preferably used on a callee side and a caller side with respect to calling of the procedures. In this case, a procedure calling relation is checked in a compiling or linking operation, and registers are assigned such that the registers used on the caller and callee sides do not overlap each other. However, the register assignment can be performed only when very severe conditions are satisfied, e.g., when a target procedure is called from only one portion or when the calling does not depend on the input series of a program. For this reason, in many cases, since assignment must be performed without recognizing the use state of the registers when a procedure is called, assignment means is not used effectively.
As described above, in a conventional computer, register assignment cannot be performed sufficiently using hardware resources. Although there is an empty register, a register in use may be assigned without assigning the empty register. Therefore, in the conventional machine, registers which need not be saved/returned must be saved/returned.
The following method is known. Registers which are returned in procedure calling and registers which are not returned are permanently classified, and the number of registers subjected to saving/returning operations in the procedure calling is decreased, thereby decreasing the load of the saving/returning operations. However, according to this method, when registers of one type are short, since registers of the other type cannot be used as the registers of one type, the registers cannot be effectively used.
In addition, in a computer program, after the value of a register is defined, the value is to be referred to. However, when the program has an error, the value may be referred to without defining the value. The program must be detected before the program is executed or during execution of the program. However, in a conventional technique, even when a program is analyzed by software before the program is executed, a relation between the definition and reference of the value is not always detected. In addition, since there is no analyzing means during execution of the program, reference of an undefined register cannot be easily checked.
With the above arrangement, in a conventional computer, it is not realized which register is generally required after a program is continued. Therefore, all registers including registers which need not be saved are saved. On the other hand, as in returning registers, all registers which need not be returned are returned. This is an important factor of prolonging an execution time of the program.
Related arts of the present invention are U.S. Pat. No. 5,021,993 and U.S. Pat. No. 4,945, 510.